 package CurtainDesign;

 import CurtainDesign.utils.CurtainChecker;
 import CurtainDesign.utils.Encoder;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.Frame;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.WindowEvent;
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JPasswordField;
 import javax.swing.JRootPane;
 import javax.swing.JTextField;
 import javax.swing.border.Border;

 public class Login extends JDialog
 {
   private static final long serialVersionUID = 1L;
   private JTextField txtUserName = new JTextField("");

   private JPasswordField pwd = new JPasswordField("");

   private JButton okbt = new JButton("确定");

   private JButton cancelbt = new JButton("取消");

   public Login(Frame owner)
   {
     super(owner, true);
     setSize(new Dimension(328, 240));
     setTitle("登录");
     jbInit();
     initListener();
   }

   private void jbInit()
   {
     JPanel contentpane = (JPanel)getContentPane();
     contentpane.setLayout(new BorderLayout());

     JPanel uppane = new JPanel();
     JPanel botpane = new JPanel();
     contentpane.add(uppane, "Center");
     contentpane.add(botpane, "South");

     GridBagLayout gbl = new GridBagLayout();
     GridBagConstraints gbc = new GridBagConstraints();
     uppane.setLayout(gbl);
     Border border = BorderFactory.createLineBorder(Color.gray, 2);
     uppane.setBorder(border);

     gbc.fill = 2;
     gbc.anchor = 13;
     gbc.insets = new Insets(15, 15, 15, 15);

     gbc.gridwidth = 1;
     gbc.ipadx = 5;
     gbc.ipady = 5;
     JLabel lblUser = new JLabel("用户");
     lblUser.setFont(new Font("Dialog", 0, 13));
     uppane.add(lblUser, gbc);

     gbc.gridwidth = 0;
     gbc.ipadx = 150;
     gbc.ipady = 0;
     this.txtUserName.setFont(new Font("Dialog", 0, 13));
     uppane.add(this.txtUserName, gbc);

     gbc.gridwidth = 1;
     gbc.ipadx = 5;
     gbc.ipady = 5;
     JLabel lblPwd = new JLabel("密码");
     lblPwd.setFont(new Font("Dialog", 0, 13));
     uppane.add(lblPwd, gbc);

     gbc.gridwidth = 0;
     gbc.ipadx = 150;
     gbc.ipady = 0;
     this.pwd.setFont(new Font("Dialog", 0, 13));
     uppane.add(this.pwd, gbc);

     botpane.setLayout(new FlowLayout());
     this.okbt.setFont(new Font("Dialog", 0, 13));
     this.cancelbt.setFont(new Font("Dialog", 0, 13));
     botpane.add(this.okbt);
     botpane.add(this.cancelbt);

     contentpane.getRootPane().setDefaultButton(this.okbt);
   }

   private void initListener()
   {
     this.okbt.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ae) {
         String name = Login.this.txtUserName.getText();
         String password = Login.this.pwd.getText();
         if (CurtainChecker.isEmpty(name))
         {
           Login.this.getToolkit().beep();
           JOptionPane.showMessageDialog(null, "用户名不能为空!", "错误", 0);
           return;
         }
         if (CurtainChecker.isEmpty(password))
         {
           Login.this.getToolkit().beep();
           JOptionPane.showMessageDialog(null, "密码不能为空!", "错误", 0);
           return;
         }
         if ((name.equals(Constants.sysUser)) && (Encoder.encryptPassword(password).equals(Constants.sysPwd)))
         {
           Login.this.dispose();
         }
         else
         {
           Login.this.getToolkit().beep();
           JOptionPane.showMessageDialog(null, "用户名和密码不符!", "错误", 0);
           Login.this.txtUserName.setText("");
           Login.this.pwd.setText("");
           return;
         }
       }
     });
     this.cancelbt.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ae) {
         System.exit(0);
       } } );
   }

   protected void processWindowEvent(WindowEvent e) {
     super.processWindowEvent(e);
     if (e.getID() == 201) {
       dispose();
       System.exit(0);
     }
   }
 }

/* Location:           C:\Users\Administrator\Desktop\奥特百叶窗\Shutter DesignerV3.1\CurtainDesign.jar
 * Qualified Name:     CurtainDesign.Login
 * JD-Core Version:    0.6.0
 */